package com.jzb.binmvvmlib.http.interceptor;

import android.util.Log;

import com.google.gson.Gson;

import java.util.Map;

import okhttp3.MediaType;
import okhttp3.RequestBody;

/**
 * author jzb
 * Date: 2021/4/7
 * Describe:
 */
public class JsonRequestBody {

    private static final String TAG = "JsonRequestBody";

    public static RequestBody getRequestBody(Map<String, Object> map) {
        RequestBody body = RequestBody.create(MediaType.parse("application/json; charset=utf-8"), getRequestJson(map));
        return body;
    }
    private static String getRequestJson(Map<String, Object> paramMap) {
        Gson gson = new Gson();
        String jsonStr = gson.toJson(paramMap);
        Log.e(TAG, "getRequestJson: " + jsonStr);
        return jsonStr;
    }
}
